package com.aaa.system.service.impl;

import com.aaa.entity.User;
import com.aaa.system.dao.UserDao;
import com.aaa.system.service.UserService;
import com.aaa.system.vo.UserVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @program: aaa-education-parent
 * @description:
 * @author: 闫克起2
 * @create: 2024-03-06 11:29
 **/
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;
    @Override
    public User queryByName(String name) {
        QueryWrapper<User> wrapper=new QueryWrapper<>();
        wrapper.eq("username",name);
        wrapper.eq("is_deleted",0);
        User user = userDao.selectOne(wrapper);
        return user;
    }

    @Override
    public Page<User> selectPage(Integer current, Integer pageSize, UserVo userVo) {
        Page<User> page=new Page<>(current,pageSize);
        QueryWrapper<User> wrapper=new QueryWrapper<>();
        if(StringUtils.hasText(userVo.getUsername())){
            wrapper.like("username",userVo.getUsername());
        }
        Page<User> page1 = userDao.selectPage(page, wrapper);
        return page1;
    }
}









